<% content_for :main_title do %> Team <% end %>

<div>
  <div style="float: left">
    <%= image_tag "logos/" + @team.large_logo %>
  </div>
  <div style="float: left">
    <h2><%= @team.name %></h2>
    <h3><%= @team.full_name %></h2>
    City: <%= @team.city %><br/>
    Country: <%= @team.country %><br/>
    Foundation: <%= @team.foundation %><br/>
    Stadium: <%= link_to @team.stadium.name, :controller => :stadium, :action => :show, :id => @team.stadium if @team.stadium %><br/>
  </div>
  <div style="clear: both"></div>
</div>

<div>
  Latest championships:<br/>
  <% @championships.each do |c| %>
    <%= link_to c.full_name, :controller => :championship, :action => :team, :id => c, :team => @team %><br/>
  <% end %>
</div>

<% last_games = @team.last_n_games(5)
unless last_games.empty? %>
<h2> Last 5 games</h2>
<div class="game_score" style='font-size: 12px'>
  <% last_games.each do |@game| %>
    <div class="table_row">
      <div class="table_cell" style='width: 30%; text-align: left'>
        <%= link_to @game.phase.championship.full_name,
          { :action => "show",
            :controller => "championship",
            :id => @game.phase.championship,
          } %>
      </div>
      <div class="table_cell" style='width: 70%'>
        <%= render :partial => "championship/game_list" %>
        <div class="clearer"></div>
      </div>
      <div class="clearer"></div>
    </div>
  <% end %>
</div>
<% end %>

<% next_games = @team.next_n_games(5)
unless next_games.empty? %>
<h2> Next 5 games</h2>
<div class="game_score" style='font-size: 12px'>
  <% next_games.each do |@game| %>
    <div class="table_row">
      <div class="table_cell" style='width: 30%; text-align: left'>
        <%= link_to @game.phase.championship.full_name,
          { :action => "show",
            :controller => "championship",
            :id => @game.phase.championship,
          } %>
      </div>
      <div class="table_cell" style='width: 70%'>
        <%= render :partial => "championship/game_list" %>
        <div class="clearer"></div>
      </div>
      <div class="clearer"></div>
    </div>
  <% end %>
</div>
<% end %>

<%= render :partial => "comment/comments", :locals => { :object => @team } %>

<% content_for :sidebar do %>
  <% if logged_in? %>
    <%= link_to "Edit", :action => :edit, :id => @team %><br/>
    <%= link_to "Delete", { :action => :destroy, :id => @team }, :confirm => 'Are you sure?', :method => :post %><br/>
  <% end %>
<% end %>
